import allure
from appium.webdriver.common.appiumby import AppiumBy

from tests.app.pages.member_page import MemberPage
from tests.app.pages.wecom import Wecom


class GroupChatSetupPage(Wecom):
    __MEMBERS_NAME = AppiumBy.XPATH, ("//*[@resource-id = 'com.tencent.wework:id/jxv']/child::android.widget.FrameLayout[1]/child::*//*[@class = 'android.widget.TextView']")

    @allure.step("跳转到成员页面")
    def goto_member_page(self, member_name):
        self.find_and_click(AppiumBy.XPATH, value=f'//*[@text = "{member_name}"]')
        return MemberPage(self.driver)

    @allure.step("获取成员列表")
    def get_members_name(self):
        members_name = self.finds(self.__MEMBERS_NAME)
        return members_name
